package cn.liziguo.tank.script;

import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.entity.component.Component;

/**
 * @author Liziguo
 * @date 2022-07-10 15:57:33
 */
public class HpBarComponent extends Component {

    private final Entity owner;

    public HpBarComponent(Entity owner) {
        this.owner = owner;
    }

    @Override
    public void onUpdate(double tpf) {
        if (owner.isActive()) {
            entity.setPosition(owner.getCenter());
        } else {
            entity.removeFromWorld();
        }
    }
}
